# Maintainer: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Ronald van Haren <ronald.archlinux.org>
# Contributor: Thomas Bächler <thomas.archlinux.org>

pkgname=ntfs-3g
_pkgname=ntfs-3g_ntfsprogs
pkgver=2022.10.3
pkgrel=1
pkgdesc='NTFS filesystem driver and utilities'
url='https://www.tuxera.com/community/open-source-ntfs-3g/'
arch=('x86_64')
license=('GPL2')
depends=('util-linux' 'fuse2')
source=("https://tuxera.com/opensource/${_pkgname}-${pkgver}.tgz")
sha256sums=('f20e36ee68074b845e3629e6bced4706ad053804cbaf062fbae60738f854170c')

conflicts=('ntfsprogs')
provides=('ntfsprogs')
replaces=('ntfsprogs')

prepare() {
  cd ${_pkgname}-${pkgver}
  sed 's|$(DESTDIR)/sbin|$(DESTDIR)/usr/bin|' -i {ntfsprogs,src}/Makefile.in
}

build() {
  cd ${_pkgname}-${pkgver}
  ./configure \
    --prefix=/usr \
    --sbin=/usr/bin \
    --mandir=/usr/share/man \
    --disable-ldconfig \
    --disable-static \
    --with-fuse=external \
    --enable-xattr-mappings \
    --enable-posix-acls \
    --enable-extras \
    --enable-crypto \

  make
}

package_ntfs-3g() {
  cd ${_pkgname}-${pkgver}
  make DESTDIR="${pkgdir}" rootbindir=/usr/bin rootsbindir=/usr/bin rootlibdir=/usr/lib install
  rm "${pkgdir}"/usr/share/man/man8/ntfsfallocate.8 # uninstalled binary
  ln -s /usr/bin/ntfs-3g "${pkgdir}/usr/bin/mount.ntfs"
}
